﻿$(function () {
    $("#rdoRenShenBingFaZheng15").click(function () {
        if ($(this).prop("checked"))
            $("#txtRenShenBingFaZheng_Text").show();
        else
            $("#txtRenShenBingFaZheng_Text").hide();
    });

    $("#rdoRenShenHeBingZheng19").click(function () {
        if ($(this).prop("checked"))
            $("#txtRenShenHeBingZheng_Text").show();
        else
            $("#txtRenShenHeBingZheng_Text").hide();
    });

    $('#btnSearch').click(function () {
        location.reload();
    });

    getParturition();
});

function getParturition() {
    $.ajax({
        url: "/NursingForm/Parturition/GetParturition?ram" + Math.random(),
        type: "post",
        data: { patientId: $("#hdnPatientId").val(), visitId: $("#hdnVisitId").val() },
        success: function (r) {
            var d = $.parseJSON(r);
            if (d.Result == 1) {
                var data = d.Body;
                for (var key in data) {
                    if (key == "RenShenBingFaZheng" || key == "RenShenHeBingZheng") {
                        var values = data[key].split('#');
                        for (var i = 0; i < values.length; i++) {
                            if (values[i] == 1) {
                                $("#rdo" + key + i).click();
                            }
                        }
                    }
                    else if (key == "FenMianFangShi" || key == "FenMianFangShi2") {
                        if ($("#txtFenMianFangShi_Text").is(':hidden')) {
                            if (data[key] == "其他") {
                                $("#txtFenMianFangShi_Text").show();
                            }
                        }
                        $("#txt" + key).val(data[key]);

                    }
                    else {
                        $("#txt" + key).val(data[key]);
                    }
                }
            }
        },
        error: function () {
            $.ligerDialog.error("程序错误");
        }
    });
}

